package Class.Calendar;

import java.time.Month;
import java.util.Calendar;

public class CalenderDemo {
    /* static Calendar getInstance()
        使用默认时区和语言环境获得一个日历
    */
    /*
     * 常用方法：
     *  public int get (int field) 返回给定日历字段的值
     * YEAR 年
     * MONTH 月(从0开始，用的时候+1)
     * DAY_OF_MONTH 月中的天
     * HOUR 时
     * MINUTE 分
     * SECOND 秒
     */
    public static void main(String[] args) {
        Calendar c = Calendar.getInstance();
        int year=c.get(Calendar.YEAR);
        System.out.println(year);
        System.out.println("********************");
        /*使用set方法设置年月日*/
        c.set(Calendar.YEAR,9999);
        year=c.get(Calendar.YEAR);
        System.out.println(year);
        int month=c.get(Calendar.MONTH)+1;
        System.out.println(month);
        System.out.println("********************");

        c.set(Calendar.DAY_OF_MONTH,4);
        month = c.get(Calendar.MONTH);
        System.out.println(c.get(1));
        System.out.println(c.get(2));
        System.out.println(c.get(3));
        System.out.println(c.get(4));
        System.out.println(c.get(5));
        System.out.println(c.get(6));
    }
}
